﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace ShadowGame
{
    public class ClueDirection : GameComponent
    {
        private Texture2D directionTexture;
        private string animation;

        public ClueDirection(ContentManager content, string animation) : base(null)
        {
            this.animation = animation;
            directionTexture = content.Load<Texture2D>(@"Images\Directions");
            animations.Add("direction", new Animation(directionTexture, 56, 56, calcDirection(), 1, "direction"));
            animations["direction"].LoopAnimation = true;
            animations["direction"].FrameLength = 0.5f;
            frameWidth = 56;
            frameHeight = 56;
            drawDepth = 0.825f;
            enabled = false;
            PlayAnimation("direction");
        }

        public Rectangle calcDirection()
        {
            Rectangle d;
            switch (animation)
            {
                case "upLeft":
                    d = new Rectangle(0, 0, 56, 56);
                    break;
                case "upRight":
                    d = new Rectangle(112, 0, 56, 56);
                    break;
                case "downLeft":
                    d = new Rectangle(0, 112, 56, 56);
                    break;
                case "downRight":
                    d = new Rectangle(112, 112, 56, 56);
                    break;
                case "right":
                    d = new Rectangle(112, 56, 56, 56);
                    break;
                case "up":
                    d = new Rectangle(56, 0, 56, 56);
                    break;
                case "down":
                    d = new Rectangle(56, 112, 56, 56);
                    break;
                case "left":
                    d = new Rectangle(0, 56, 56, 56);
                    break;
                default:
                    d = new Rectangle(0, 0, 56, 56);
                    break;
            }
            return d;
        }
    }
}
